﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Microsoft.WindowsAzure.StorageClient;
using System.ComponentModel;

namespace LCA.Community.DAL.Model
{
    /// <summary>
    /// This class defines a question made by a user
    /// 
    /// RowKey = The question ID
    /// PartitionKey = The author of the question
    /// </summary>
    public class Question : BasicDataModel
    {
        #region Fields
        private IList<Answer> answers; 
        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="Question"/> class.
        /// </summary>
        public Question()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Question"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="title">The title.</param>
        /// <param name="author">The author.</param>
        /// <param name="body">The body.</param>
        /// <param name="creationDate">The creation date.</param>
        public Question(String title, string author, string body, DateTime creationDate)
        {
            this.RowKey = Guid.NewGuid().ToString();
            this.PartitionKey = author;
            this.Title = title;
            this.Body = body;
            this.Timestamp = creationDate;
        }

        /// <summary>
        /// Gets or sets the title of the question.
        /// </summary>
        /// <value>The title.</value>
        [Required(ErrorMessage = "Debe introducir un título.")]
        [DisplayName("Título")]
        public string Title { get; set; }
        /// <summary>
        /// Gets or sets the author of the question.
        /// </summary>
        /// <value>The author.</value>
        [Required(ErrorMessage = "Debe introducir un autor.")]
        [DisplayName("Autor")]
        public string Author 
        { 
            get
            {
                return PartitionKey;
            }
            set
            {
                PartitionKey = value;
            }
        }
        /// <summary>
        /// Gets or sets the body of the question.
        /// </summary>
        /// <value>The body.</value>
        [DisplayName("Pregunta")]
        public string Body { get; set; }
        /// <summary>
        /// Gets or sets the tags of the question.
        /// </summary>
        /// <value>The tags.</value>
        [DisplayName("Etiqueta")]
        public string Tags { get; set; }
    }
}